fix: wrong order of resolving function expression and operands expression for call_indirect#2994
fix: wrong order of resolving function expression and operands expression for call_indirect#2994Changqing-JING wants to merge 2 commits intoAssemblyScript:mainfrom
Conversation
…pression for call_indirect (#429) carry over from AssemblyScript/assemblyscript#2994
|
Can some maintainer help to review this PR? |
|
It makes the semantics of as and ts more consistent, with a slight performance loss, yet I believe this trade-off is worthwhile. @MaxGraey WDYT? |
|
I'm not sure. I think AssemblyScript provides much more obvious and logical approach. JavaScript has historically had a lot of quirks, and I think this is one of them. Also, it's breaking change |
|
@MaxGraey In my opinion, the assemblyscript need to follow typescript/javascript design
|
|
Oh, now I see. Сallee should be saved before args run. Otherwise, side effects can swap the function under your feet, which is pretty footgun-y. |
|
It will be great to add smoke test for compiler which check correct order in output. Something like: function origCallback(x: i32): void {
trace(`called origCallback with ${x}`);
}
function replacedCallback(x: i32): void {
trace(`called replacedCallback with ${x}`);
}
let cb = origCallback;
function newCallback(): i32 {
trace("inside newCallback, replacing cb");
cb = replacedCallback;
return 42;
}
trace("before call");
cb(newCallback());
trace("after call"); |
Fixes #2989
Changes proposed in this pull request:
Fix wrong order of resolving function expression and operands expression for call_indirect